﻿@model Isaac.Joy.Identity.Web.DtCms.Models.RoleViewModel
@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>编辑用户</title>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/jquery-1.10.2.min.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/Validform_v5.3.2.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/lhgdialog/lhgdialog.js?skin=idialog")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/datepicker/WdatePicker.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/layout.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/json2.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/errorCode.js")"></script>
    <script type="text/javascript" src="@Url.BundleContent("~/Scripts/jqueryStatic.js")"></script>
    <link type="text/css" href="@Url.BundleContent("~/css/style.css")" rel="stylesheet" />
    <script type="text/javascript">
        $(function () {
            var mainform = $("#mainform").Validform({ tiptype: dtcmstiptype, showAllError: true });

            $("#btnSubmit").click(function () {
                if (!mainform.check()) return false;

                var pvalue = "";

                $("input[name='cblPermission']").each(function () {
                    if ($(this).prop("checked")) {
                        pvalue = pvalue + $(this).val() + ",";
                    }
                });

                $.ajax({
                    url: '@Url.Action("AjaxEdit")',
                    type: "post",
                    data: "Role.Name=" + $("#txtName").val() +
                        "&Role.Id=" + $("#Roleid").val() +
                        "&RoleValue=" + pvalue +
                        "",
                    processData: false,
                    success: function (response) {
                        var data = JSON.parse(response);
                        errorCode.getMsg(data, function () {
                            if (data.success) {
                                $.dialog.alert('修改成功！', function () {
                                    document.location.reload();
                                }, null, "提示");
                            } else {
                                $.dialog.alert('修改失败！');
                            }
                        }, function (e) {
                            $.dialog.alert(data.msg == '' ? e.msg : data.msg);
                        });
                        return false;
                    }
                });
                return false;
            });
        });
    </script>
</head>

<body class="mainbody">
    <div id="mainform">
        <!--导航栏-->
        <div class="location">
            <a href="user_list.aspx" class="back"><i></i><span>返回列表页</span></a>
            <a href="../center.aspx" class="home"><i></i><span>首页</span></a>
            <i class="arrow"></i>
            <span>会员管理</span>
            <i class="arrow"></i>
            <span>编辑用户</span>
        </div>
        <div class="line10"></div>
        <!--/导航栏-->

        <!--内容-->
        <div class="content-tab-wrap">
            <div id="floatHead" class="content-tab">
                <div class="content-tab-ul-wrap">
                    <ul>
                        <li><a href="javascript:;" onclick="tabs(this);" class="selected">基本资料</a></li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="tab-content">
            <dl>
                <dt>角色名称</dt>
                <dd>
                    <input type="text" id="txtName" value="@Model.Role.Name" class="input normal" datatype="*2-200" sucmsg=" " />
                    <span class="Validform_checktip">*角色名称</span>
                </dd>
            </dl>
            <dl>
                <dt>权限设置</dt>
                <dd>
                    <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="98%">
                        <thead>
                            <tr>
                                <th width="15%">插件</th>
                                <th style="text-align: left;">权限</th>
                            </tr>
                        </thead>
                        <tbody id="var_box">
                            @foreach (var key in Model.Permissions.Keys)
                            {
                                <tr>
                                    <td style="white-space: nowrap; word-break: break-all; overflow: hidden; text-align: center;">@key</td>
                                    <td style="white-space: nowrap; word-break: break-all; overflow: hidden;">
                                        <div class="rule-multi-checkbox">
                                            <span id="cblItem">
                                                @foreach (var permission in @Model.Permissions[key])
                                                {
                                                    if (Model.Role.FlagsValue.Enabled(0))
                                                    {
                                                    <input id="cblItem_@permission.Id" type="checkbox" name="cblPermission" value="@permission.Id" disabled="disabled" checked="checked" /><label for="cblItem_@permission.Id">@permission.Name</label>
                                                    }
                                                    else if (Model.Role.FlagsValue.Enabled(permission.Id))
                                                    {
                                                    <input id="cblItem_@permission.Id" type="checkbox" name="cblPermission" value="@permission.Id" checked="checked" /><label for="cblItem_@permission.Id">@permission.Name</label>
                                                    }
                                                    else
                                                    {
                                                    <input id="cblItem_@permission.Id" type="checkbox" name="cblPermission" value="@permission.Id" /><label for="cblItem_@permission.Id">@permission.Name</label>
                                                    }
                                                }
                                            </span>
                                        </div>
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
            </dl>
        </div>
        <!--/内容-->

        <!--工具栏-->
        <div class="page-footer">
            <div class="btn-list">
                <input type="hidden" id="Roleid" value="@Model.Role.Id" />
                @if (!Model.Role.FlagsValue.Enabled(0))
                {
                    <input type="button" value="提交保存" id="btnSubmit" class="btn" />
                }
                @*<input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />*@
            </div>
            <div class="clear"></div>
        </div>
        <!--/工具栏-->
    </div>
</body>
</html>

